package com.aaa.member.controller;

import com.aaa.common.constants.ReturnCode;
import com.aaa.common.util.Result;
import com.aaa.member.entity.MemberLevel;
import com.aaa.member.service.MemberLevelService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (MemberLevel)表控制层
 *
 * @author LiangLei
 * @since 2020-11-19 14:17:45
 */
@RestController
@RequestMapping("memberLevel")
public class MemberLevelController {
    /**
     * 服务对象
     */
    @Resource
    private MemberLevelService memberLevelService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public MemberLevel selectOne(Integer id) {
        return this.memberLevelService.queryById(id);
    }

    /**
     *  分页
     */
    @GetMapping("queryPageByParam")
    Result queryPageByParam(Integer pageNo, Integer pageSize, MemberLevel memberLevel){
        return this.memberLevelService.queryAllByParam(pageNo,pageSize,memberLevel);
    }



    @PostMapping("add")
    public Result add(@RequestBody MemberLevel memberLevel){
        //返回成功
        return new Result(ReturnCode.SUCCESSS.getCode(),
                ReturnCode.SUCCESSS.getMsg(),this.memberLevelService.insert(memberLevel));
    }



    @DeleteMapping("delete")
    public Result delete(Integer id){
        //返回成功
        return new Result(ReturnCode.SUCCESSS.getCode(),
                ReturnCode.SUCCESSS.getMsg(),this.memberLevelService.deleteById(id));
    }




    /**
     * 更新
     * @param memberLevel
     * @return
     */
    @PutMapping("update")
    public Result update(@RequestBody MemberLevel memberLevel){
        return new Result(ReturnCode.SUCCESSS.getCode(),
                ReturnCode.SUCCESSS.getMsg(),this.memberLevelService.update(memberLevel));
    }



}